<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  
    
      
    

    
  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="blog,hexo," />








  <link rel="shortcut icon" type="image/x-icon" href="/images/custom/favicon.ico?v=5.1.0" />






<meta name="description" content="在IT界混下去没有blog怎么能行呢？ 以上纯属玩笑，因为有了blog可以记录下平时生活的点点滴滴也可以分享下相关技术心得更可以记录工作中遇到的问题。多说不宜，那就开始步入整体吧，此次blog搭建主要是采用 hexo + githup, 下面就 follow me 一起按照步骤开始开启blog之旅吧。  准备工作  如果你想对外可以访问，首先申请github帐号 新建仓库，命名格式: 用">
<meta name="keywords" content="blog,hexo">
<meta property="og:type" content="article">
<meta property="og:title" content="blog搭建小记">
<meta property="og:url" content="http://www.zhangxiaoheng.cn/2017/03/26/blog-study/index.html">
<meta property="og:site_name" content="Change The World">
<meta property="og:description" content="在IT界混下去没有blog怎么能行呢？ 以上纯属玩笑，因为有了blog可以记录下平时生活的点点滴滴也可以分享下相关技术心得更可以记录工作中遇到的问题。多说不宜，那就开始步入整体吧，此次blog搭建主要是采用 hexo + githup, 下面就 follow me 一起按照步骤开始开启blog之旅吧。  准备工作  如果你想对外可以访问，首先申请github帐号 新建仓库，命名格式: 用">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://www.zhangxiaoheng.cn/2017/03/26/blog-study/io.png">
<meta property="og:image" content="http://www.zhangxiaoheng.cn/2017/03/26/blog-study/anly.png">
<meta property="og:image" content="http://www.zhangxiaoheng.cn/2017/03/26/blog-study/ip.png">
<meta property="og:updated_time" content="2017-03-26T05:41:16.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="blog搭建小记">
<meta name="twitter:description" content="在IT界混下去没有blog怎么能行呢？ 以上纯属玩笑，因为有了blog可以记录下平时生活的点点滴滴也可以分享下相关技术心得更可以记录工作中遇到的问题。多说不宜，那就开始步入整体吧，此次blog搭建主要是采用 hexo + githup, 下面就 follow me 一起按照步骤开始开启blog之旅吧。  准备工作  如果你想对外可以访问，首先申请github帐号 新建仓库，命名格式: 用">
<meta name="twitter:image" content="http://www.zhangxiaoheng.cn/2017/03/26/blog-study/io.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://www.zhangxiaoheng.cn/2017/03/26/blog-study/"/>





  <title>blog搭建小记 | Change The World</title>
  














</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Change The World</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">沉默是一种力量</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="http://www.zhangxiaoheng.cn/2017/03/26/blog-study/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Tom">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/custom/ava.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Change The World">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">blog搭建小记</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-03-26T12:55:15+08:00">
                2017-03-26
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p>    在IT界混下去没有blog怎么能行呢？<br>
以上纯属玩笑，因为有了<code>blog</code>可以记录下平时生活的点点滴滴也可以分享下相关技术心得更可以记录工作中遇到的问题。多说不宜，那就开始步入整体吧，此次<code>blog</code>搭建主要是采用 <code>hexo + githup</code>, 下面就 <code>follow me</code> 一起按照步骤开始开启blog之旅吧。</p>
</blockquote>
<h3>准备工作</h3>
<ol>
<li>如果你想对外可以访问，首先申请<a href="https://github.com/" title="github" target="_blank" rel="external"><code>github</code></a>帐号</li>
<li>新建仓库，命名格式: <code>用户名.githup.io</code> 点击完成，如下图:</li>
</ol>
<p><img src="/2017/03/26/blog-study/io.png" alt="仓库名称"></p>
<p>目前完成了万里长征的第一步,<code>go on...</code></p>
<h3>安装<code>blog</code>环境‌</h3>
<ul>
<li>安装<a href="https://nodejs.org/en/" title="NODE.JS" target="_blank" rel="external"><code>node.js</code>官网</a>，<a href="http://nodejs.cn/download/" title="node.js" target="_blank" rel="external">中文网</a>，用于生成静态页面</li>
</ul>
<ol start="2">
<li>安装<a href="https://git-scm.com/" title="git" target="_blank" rel="external"><code>git</code></a>,网盘（windows）<a href="http://pan.baidu.com/s/1pKXcpi7" title="git" target="_blank" rel="external">安装包</a>,安装git主要是把hexo生成的blog站点提交到github</li>
<li>全局安装 <code>hexo</code></li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ npm install -g hexo --save</div></pre></td></tr></table></figure>
<ol start="4">
<li>新建站点文件夹（以下没有特别说明均在此文件夹下执行），进行初始化</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo init</div></pre></td></tr></table></figure>
<ol start="5">
<li>生成<code>blog</code>静态页面</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo generate （或 hexo g）</div></pre></td></tr></table></figure>
<ol start="6">
<li>本地启动，进行预览</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo server （或 hexo s）</div></pre></td></tr></table></figure>
<p><code>blog</code>站点预览地址：<a href="http://localhost:4000" title="预览" target="_blank" rel="external">http://localhost:4000</a></p>
<h3>配置<code>Github</code></h3>
<ul>
<li>修改站点文件夹下的<code>_config.yml</code>文件，找到<code>deploy</code>位置，修改如下：</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">deploy: </div><div class="line">  <span class="built_in">type</span>: git </div><div class="line">  repository: https://github.com/zzhtom/zzhtom.github.io.git  </div><div class="line">  branch: master</div></pre></td></tr></table></figure>
<ul>
<li>安装<code>git</code>部署的插件</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ npm install hexo-deployer-git --save</div></pre></td></tr></table></figure>
<ul>
<li>部署到<code>github</code></li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo deploy (或 hexo d)</div></pre></td></tr></table></figure>
<ul>
<li><code>hexo</code> 常用命令</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">hexo clean                清理生成的blog页面    </div><div class="line">hexo generate             生成静态页面  </div><div class="line">hexo deploy               部署页面到github  </div><div class="line">hexo new <span class="string">"postName"</span>       新建文章  </div><div class="line">hexo new page <span class="string">"pageName"</span>  新建页面  </div><div class="line">hexo server               开启本地服务  </div><div class="line">hexo <span class="built_in">help</span>                 查看帮助  </div><div class="line">hexo version              查看Hexo的版本</div></pre></td></tr></table></figure>
<h3>配置域名访问</h3>
<ul>
<li>注册域名，如<a href="https://wanwang.aliyun.com/" title="阿里云" target="_blank" rel="external">阿里云</a>、<a href="https://dnspod.qcloud.com/?from=qcloudHome" title="腾讯云" target="_blank" rel="external">腾讯云</a></li>
<li>进行域名解析设置</li>
</ul>
<p><img src="/2017/03/26/blog-study/anly.png" alt="域名解析"></p>
<ul>
<li>进行<code>ip</code>指向，<code>ip</code>为<code>github</code>访问路径的解析<code>ip</code>,如下图：</li>
</ul>
<p><img src="/2017/03/26/blog-study/ip.png" alt="ip地址"></p>
<ul>
<li>进行域名指向，指向域名即为 <code>用户名.github.io</code></li>
</ul>
<h3>网站推荐</h3>
<p><a href="https://hexo.io/" title="hexo" target="_blank" rel="external"><code>hexo</code>官网</a><br>
<a href="http://theme-next.iissnan.com/" title="next" target="_blank" rel="external"><code>Next</code>主题</a><br>
<a href="http://baixin.io/2015/08/HEXO%E6%90%AD%E5%BB%BA%E4%B8%AA%E4%BA%BA%E5%8D%9A%E5%AE%A2/" title="blog" target="_blank" rel="external">博客推荐</a><br>
本人<a href="http://www.zhangxiaoheng.cn" title="blog"><code>blog</code></a> <a href="http://www.zhangxiaoheng.cn" title="blog">www.zhangxiaoheng.cn</a> 欢迎来访</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/images/custom/wechat.png" alt="Tom WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="/images/custom/alipay.jpg" alt="Tom Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/blog/" rel="tag"># blog</a>
          
            <a href="/tags/hexo/" rel="tag"># hexo</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/06/26/shell-seconds/" rel="prev" title="内置变量SECONDS小记">
                内置变量SECONDS小记 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
  <a class="jiathis_button_tsina"></a>
  <a class="jiathis_button_tqq"></a>
  <a class="jiathis_button_weixin"></a>
  <a class="jiathis_button_cqq"></a>
  <a class="jiathis_button_douban"></a>
  <a class="jiathis_button_renren"></a>
  <a class="jiathis_button_qzone"></a>
  <a class="jiathis_button_kaixin001"></a>
  <a class="jiathis_button_copy"></a>
  <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a>
  <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
  var jiathis_config={
    hideMore:false
  }
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END -->

      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="uyan_frame"></div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/custom/ava.jpg"
               alt="Tom" />
          <p class="site-author-name" itemprop="name">Tom</p>
           
              <p class="site-description motion-element" itemprop="description">一名不知所措的IT从业者</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">5</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">10</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/zzhtom" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/2958802633" target="_blank" title="Weibo">
                  
                    <i class="fa fa-fw fa-weibo"></i>
                  
                  Weibo
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.jianshu.com/u/806a589bd7f0" target="_blank" title="简书">
                  
                    <i class="fa fa-fw fa-book"></i>
                  
                  简书
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">1.</span> <span class="nav-text">准备工作</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">2.</span> <span class="nav-text">安装blog环境‌</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">3.</span> <span class="nav-text">配置Github</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">4.</span> <span class="nav-text">配置域名访问</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#undefined"><span class="nav-number">5.</span> <span class="nav-text">网站推荐</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Tom</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  


  




	





  
    

    
      <!-- UY BEGIN -->
      <script type="text/javascript" src="http://v2.uyan.cc/code/uyan.js?uid=2137531"></script>
      <!-- UY END -->
    
  





  






  





  

  

  

  

  

  

</body>
</html>
